<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title>Parent Informer RCSHS - Settings Lobby</title>
<link rel=stylesheet href="../../css-layouts/themes/defaulttheme.css" type="text/css">
<link rel=stylesheet href="../../css-layouts/headlinks.css" type="text/css">

<script src="../../jsc/settingsjs.js" type="text/javascript"></script>
<script src="../../jsc/ajax.js" type="text/javascript"></script>

<script type="text/javascript">
<!--
 function editusrnm() {
  var condme = confirm('Are you sure you want to change your username? Click OK to change.');
  if(condme==true) {
   var genUsr = document.createElement("input");

   genUsr.setAttribute("type", "text");
   genUsr.setAttribute("name", "newusrnm");
   genUsr.setAttribute("value", "<?php echo $_COOKIE['parentinformerprcshs']; ?>");

   document.getElementById('usrtxt').innerHTML='';
   document.getElementById('usrtxt').appendChild(genUsr);
   document.getElementById('usrbtn').innerHTML='';
  }
 }
 
//-->
</script>

<style type="text/css">

div#applogo {
 background: url(../../img/themes/default/headers/logintitle.jpg) -10px -5px;
 width: 490px;
 height: 60px;
 margin-left: auto;
 margin-right: auto;
 border: 2px solid #FFFFF0;
}

</style>
</head>

<body>

<?php 

 require_once("../../sqlconfig.php");

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error()); 
 mysql_select_db($mydb) or die(mysql_error());

 //Checks if there is a login cookie
 if(isset($_COOKIE["parentinformerprcshs"]) || isset($_COOKIE["parentinformerurcshs"])) { 
  if(isset($_COOKIE["parentinformerprcshs"])) {
   $username = $_COOKIE["parentinformerprcshs"]; 
  }
  else {
   $_SESSION['theerrcode'] = 2;
   header("Location: ../logerr_atmpt.php");
  }
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    $_SESSION['theerrcode'] = 2;
    header("Location: ../logerr_atmpt.php");
   }
   else {

?>

<script type="text/javascript">
<!--
 function chiasmus() {
  /*
   * The function chiasmus() transfers the values inputted in the
   * profile tab to the general tab using hidden fields.
   */
  var stat = <?php echo $info['priv']; ?>;
  if(stat == 1 || stat == 2) {

   var profPgr = document.createElement("input");
   var profMnt = document.createElement("input");
  
   profPgr.setAttribute("type", "hidden");
   profPgr.setAttribute("name","pgr");
   profPgr.setAttribute("value", document.forms['profset'].passgr.value);

   profMnt.setAttribute("type", "hidden");
   profMnt.setAttribute("name","mnt");
   profMnt.setAttribute("value", document.forms['profset'].maildef.value);

   document.forms['genset'].appendChild(profPgr);
   document.forms['genset'].appendChild(profMnt);
  }
  
  var profThm = document.createElement("input");
  profThm.setAttribute("type", "hidden");
  profThm.setAttribute("name","thm");
  profThm.setAttribute("value", document.forms['profset'].themesel.options[document.forms['profset'].themesel.selectedIndex].value);
  document.forms['genset'].appendChild(profThm);
 }
 
//-->
</script>

<div id="mainhead"><br><br><br></div>


<p class="leftnav">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logged in as: <?php echo $_COOKIE["parentinformerprcshs"]; ?>
</p>

<p class="rightnav">

<?php

if($info['priv']==1) {
 echo "<a href='../acctmgnt'>Account Management</a> || ";
}

?>
<b>Settings</b> || <a href="../redirout.php">Logout</a>
</p>

<hr style="clear: both;"><br>

<center><font id="heading">SETTINGS</font></center>

<ol id="tabs">
<li><a href="#general"><span>General</span></a></li>
<li><a href="#profile"><span>Profile</span></a></li>
<li><a href="#about"><span>About</span></a></li>
</ol>

<!-- GENERAL SETTINGS -->

<div class="tabcontent" id="general">

<form method=post id="genset" action="">
<table id="settingslayout">

<tr>
<td>USERNAME:</td>
<td><span id="usrtxt"><?php echo $_COOKIE["parentinformerprcshs"]; ?></span></td>
<td><span id="usrbtn"><input type="button" value="CHANGE" id="repusr" name="repusr" onclick="editusrnm();"></span></td>
</tr>

<tr>
<td><span id="oldpasstxt">PASSWORD:</span></td>
<td><span id="oldpassfld">Not shown...</span></td>
<td><span id="passbtn"><input type="button" value="CHANGE" id="reppass" name="reppass" onclick="editpass();"></span></td>
</tr>

<tr>
<td><span id="newpasstxt"></span></td>
<td><span id="newpassfld"></span></td>
</tr>

<tr>
<td><span id="confpasstxt"></span></td>
<td><span id="confpassfld"></span></td>
</tr>

<?php
 if($info['priv']==2) {
?>

<tr>
<td>SUBJECT DEPARTMENT/S:</td>
<td>
<textarea cols="25" rows="3" id="subjdept" name="subjdept" onkeyup="shint(this.value);">
<?php echo $info['subjdept']; ?>
</textarea>
</td>
</tr>

<tr>
<td></td>
<td><span id = "subjhints" style="display: none;">...</span></td>
</tr>

<?php } ?>

<tr>
<td>E-MAIL:</td>
<td><input type="text" value="<?php echo $info['mailadd']; ?>" name="mailadd"></td>
</tr>

</table>
</form>

</div>

<!-- PROFILE SETTINGS -->

<div class="tabcontent" id="profile">

<form method=post id="profset" action="">
<table cellspacing="5">

<tr>
<td>THEME:</td>

<td>
<select name="themesel" id="themesel">
<option value="">Please choose a theme...</option>
<option value="default">DEFAULT</option>
<option value="compsci">COMPUTER SCIENCE</option>
<option value="sci">SCIENCE</option>
<option value="math">MATH</option>
<option value="school">SCHOOL</option>
</select>
</td>

</tr>

<?php

 if($info['priv'] == 1 || $info['priv'] == 2) {

?>

<tr>
<td>PASSING GRADE:</td>
<td><input type="text" name="passgr" maxlength=5 value="<?php echo $info['passgr']; ?>"></td>
</tr>

<tr>
<td>MAIL DEFAULT NOTICE:</td>

<td>
<textarea rows="10" cols="75" name="maildef">
<?php echo $info['msgdef']; ?>
</textarea>

</tr>

<?php } ?>

</table>
</form>

</div>

<!-- ABOUT PARENT INFORMER -->

<div class="tabcontent" id="about">

<div id="applogo"></div>

<p style="text-align: justify;">
Parent Informer is a web application designed for use of the students and faculty of Roosevelt College
Science High School. Its main function is to inform parents of the academic performance of students by
sending an electronic mail to the parents. It also has peripheral functions such as real-time grade
viewing, editing, and saving.
<br><br>
Have any comments or suggestions? <a id="maillink">Drop by</a>.
<br><br>
&copy; 2011 Roosevelt College Science High School. All Rights Reserved.
</p>

</div>

<table>

<tr>
<td><input type="button" value="OK" name="submitbtn" onclick="chiasmus(); submitall();"></td>
<td><input type="button" value="CANCEL" name="cancelbtn" onclick="window.location='../../';"></td>
</tr>

</table>

<?php

   }
  }
 }
 else {
  header("Location: ../../");
 }

?>

<div class="footnav" align=center>

<hr>

<a href="../../">Main Page</a> ||
<a href="#">Help</a> ||
<a href="../../externalaffairs/links.php">Links</a> ||
<a href="#">About</a>
<br>

<span id="copyme">
&copy; 2011 Roosevelt College Science High School. All rights reserved.
</span>

</div>

<script src="../../jsc/tabswitch.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
 activatables('settings', ['general', 'profile', 'about']);

 function showmailadd() {
  var mailname1 = "pinfmail";
  var domain = "gmail";
  var atsign = "@";
  var mailname2 = "rcshs";
  var dotsign = ".";
  var ext = "com";

  mailadd = "mailto:" + mailname1 + dotsign + mailname2 + atsign + domain + dotsign + ext;
  document.getElementById('maillink').href=mailadd;
 }
 showmailadd();
//-->
</script>

</body>

</html>